package cn.gok.thread;

import java.util.Random;

/**
 * @ClassName ReadThread
 * @Description TODO
 * @Author HP
 * @Date 17:26 2022/7/12
 * @Version 1.0
 **/
public class WriteThread extends Thread {
    private Person person;
    public WriteThread(Person person){
        this.person = person;
    }

    @Override
    public void run() {
        Random rd = new Random();
        int i = 0;
        while (true){
            if(i%2==0){
                person.modify("林志玲","女");
            }else {
                person.modify("周杰伦","男");
            }
            i++;
            try {
                Thread.sleep(rd.nextInt(500));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
